package com.learn.enums.service.impl;

import cn.hutool.json.JSONUtil;
import com.learn.enums.entity.User;
import com.learn.enums.service.UserService;
import com.learn.spring.cache.annotation.RedisLock;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class UserServiceImpl implements UserService {

    public static final String USER_PRE_KEY = "user:id:";

    @Override
    @RedisLock(prefix = USER_PRE_KEY, waitTime = 6L, key = "#user.id")
    public void saveUser(User user) {
        log.info("[分布式锁]==========UserServiceImpl#save==========", JSONUtil.toJsonStr(user));
    }
}
